package com.cskaoyan.day11;

public class AbstractTest {
    public static void main(String[] args) {
        Shape s1 = new Rectangle(2, 3);
        Shape s2 = new Circle(3);
        System.out.println(s1);
        System.out.println(s2);
    }
}

abstract class Shape {
    abstract public double getCircle();
    abstract public double getArea();
}

class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double getCircle() {
        return Math.PI * 2 * radius;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "radius=" + radius +
                '}' + "面积为:" + getArea() + ", 周长为: " + getCircle();
    }
}

class Rectangle extends Shape {
    private double lengthSize;
    private double wideSize;

    public Rectangle(double lengthSize, double wideSize) {
        this.lengthSize = lengthSize;
        this.wideSize = wideSize;
    }

    @Override
    public double getCircle() {
        return 2 * (lengthSize + wideSize);
    }

    @Override
    public double getArea() {
        return lengthSize * wideSize;
    }

    @Override
    public String toString() {
        return "Rectangle{" +
                "lengthSize=" + lengthSize +
                ", wideSize=" + wideSize +
                '}' + "面积为:" + getArea() + ", 周长为: " + getCircle();
    }
}